package com.yc.damai;

import com.yc.damai.entity.Product;
import com.yc.damai.web.remote.IOrderAction;
import com.yc.damai.web.remote.OrderActionImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class IndexAction {

    @Resource
    IOrderAction orderAction;

    @Resource
    OrderActionImpl orderActionImpl;

    @RequestMapping("queryIndexProduct")
    Map<String,Object> queryIndexProduct(){
        List<Product> news = orderAction.queryNews();
        List<Product> hots = orderAction.queryHots();
        orderActionImpl.cache("queryNews", news);
        orderActionImpl.cache("queryHots", hots);
        Map<String,Object> map = new HashMap<>();
        map.put("news", news);
        map.put("hots", hots);
        return map;
    }

}
